﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        gvBind();
    }
    protected void gvBind()
    {
        DataClassesDataContext db = new DataClassesDataContext();
        var user = from s in db.studentinfo select s;
        gvStudent.DataSource = user;
        gvStudent.DataBind();
    }
    protected void btnInsert_Click(object sender, EventArgs e)
    {
        DataClassesDataContext db = new DataClassesDataContext();
        var Sno = Convert.ToInt32(txtSno.Text);
        var query = from stu in db.studentinfo where stu.SNO == Sno select stu;
        foreach (studentinfo s in query)
        {
            s.SNAME = txtName.Text;
        }
        db.SubmitChanges();
        gvBind();
    }
    protected void btnInsert1_Click(object sender, EventArgs e)
    {
        DataClassesDataContext db = new DataClassesDataContext();
        var delstu = from stu in db.studentinfo where stu.SNAME == txtSno1.Text select stu;
        foreach (var s in delstu)
        {
            db.studentinfo.DeleteOnSubmit(s);
        }
        db.SubmitChanges();
        var user = from s in db.studentinfo select s; 
        gvBind();
    }
}